package com.mall.server.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mall.commons.utils.PageUtils;
import com.mall.dubbo.api.PmsBrandApi;
import com.tanhua.model.domain.PmsBrand;
import com.tanhua.model.vo.PageVo;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

@Service
public class BrandService {

    @DubboReference
    private PmsBrandApi pmsBrandApi;
    /**
     * 根据品牌名称分页获取品牌列表
     * @return
     * @param keyword
     * @param pageNum
     * @param pageSize
     */
    public PageVo list(String keyword, Integer pageNum, Integer pageSize) {
        Page<PmsBrand> page = new Page<>(pageNum, pageSize);
        page=pmsBrandApi.list(keyword,page);

        return PageUtils.getPageVo(page);
    }
    /**
     * 批量更新厂家制造商状态
     * @param ids
     * @return factoryStatus
     */
    public void updateFactoryStatus(Integer[] ids, Integer factoryStatus) {
        pmsBrandApi.updateFactoryStatus(ids,factoryStatus);
    }

    /**
     * 批量更新显示状态
     * @param ids
     * @param showStatus
     * @return
     */
    public void updateShowStatus(Integer[] ids, Integer showStatus) {
        pmsBrandApi.updateShowStatus(ids,showStatus);
    }

    /**
     * 根据编号查询品牌信息
     * @param id
     * @return
     */
    public PmsBrand findBrandById(Integer id) {
        return pmsBrandApi.findBrandById(id);
    }

    /**
     * 更新品牌
     * @param pmsBrand
     * @return
     */
    public void updateById(PmsBrand pmsBrand) {
        pmsBrandApi.updateById(pmsBrand);
    }

    /**
     * 根据id删除品牌
     * @param id
     * @return
     */
    public void deleteById(Long id) {
        pmsBrandApi.deleteById(id);
    }

    /**
     * 添加品牌
     * @param pmsBrand
     * @return
     */
    public void create(PmsBrand pmsBrand) {
        pmsBrandApi.create(pmsBrand);
    }
}
